#ifndef __WIZ_FILE_PATH_HPP__SHANHAOBO_19800429__
#define __WIZ_FILE_PATH_HPP__SHANHAOBO_19800429__

#include "../../Core/Container/WizDataTypeBuffer.hpp"
#include "../../DataType/String/WizDataTypeUTF8.hpp"

namespace Wiz
{
    namespace File
    {
        namespace Path
        {
            struct WIZ_EXPORT Type
            {
            public:
                Type(::Wiz::UTF8::String::In InPath, ::Wiz::Bool::In IsFile = ::Wiz::Bool::False);
            public:
                ::Wiz::Void::Type GetPath(::Wiz::String::Out OutStr)
                {
                    ::Wiz::UTF8::String::Type Temp;
                    ::Wiz::UCount::Type i;
                    for (i = 0; i < this->m_DirectoryOffset.Size(); i++)
                    {
                        Temp += this->m_DirectoryOffset[i] + m_Buffer.GetPtr();
                        Temp += (::Wiz::UTF8::Char::Ptr)("\\");
                    }
                    ::Wiz::UTF8::Char::Ptr FNPtr = FileNamePtr();
                    if (::Wiz::IsValidPtr(FNPtr))
                    {
                        Temp += FNPtr;
                    }

                    Temp.To(OutStr);
                }

                ::Wiz::UTF8::Char::Ptr operator[](::Wiz::UInt::In i)
                {
                    WIZ_ASSERT(i < m_DirectoryOffset.Size());
                    return m_Buffer.GetPtr() + m_DirectoryOffset[i];
                }

                ::Wiz::UTF8::Char::Ptr FileNamePtr()
                {
                    if (this->IsFile())
                    {
                        return this->m_FileOffset + m_Buffer.GetPtr();
                    }

                    return WIZ_NULLPTR;
                }

                ::Wiz::Bool::Type IsFile()
                {
                    return m_FileOffset != -1 && m_FileOffset < m_Buffer.GetElementCount();
                }

                ::Wiz::Size::Type DirectorySize()
                {
                    return m_DirectoryOffset.Size();
                }
            protected:
                ::Wiz::Void::Type Analyze(::Wiz::UTF8::String::In, ::Wiz::Bool::In IsFile);
            protected:
                struct Buffer_t : public ::Wiz::Buffer::Type<::Wiz::UTF8::Char::Type, 16, ::Wiz::Int::Type>
                {
                    Wiz::Void::Type ReplaceElement(
                        tElementIn OldEle,
                        tElementIn NewEle,
                        ::Wiz::Array::Type<::Wiz::Int::Type>& OutArray
                        );
                };
                Buffer_t                                m_Buffer;
                ::Wiz::Array::Type<::Wiz::Int::Type>    m_DirectoryOffset;
                ::Wiz::Int::Type                        m_FileOffset;
            };
        } /// end of namespace Path
    } /// end of namespace File
} /// end of namespace Wiz

#endif /*__WIZ_FILE_PATH_HPP__SHANHAOBO_19800429__*/
